package cn.yza.设计模式.单例模式;

import java.util.concurrent.atomic.AtomicLong;

/** 静态内部类
 * @author Honglixi
 * @create 2021-10-25 14:19
 */
public class SingletonTest04 {
    private AtomicLong id = new AtomicLong(0);
    private SingletonTest04() {}

    private static class SingletonHolder{
        private static final SingletonTest04 instance = new SingletonTest04();
    }

    public static SingletonTest04 getInstance() {
        return SingletonHolder.instance;
    }

    public long getId() {
        return id.incrementAndGet();
    }
}
